import { IsNotEmptyRw, IsStringRw } from '@/common/utils/class-validator';
import { Transform } from 'class-transformer';
import { IsIn, IsNumberString, IsOptional } from 'class-validator';
export class CreateDeptDto {
  @IsStringRw()
  @IsNotEmptyRw()
  name: string;

  @IsStringRw()
  @IsNotEmptyRw()
  code: string;

  // 数字或数字字符串
  @Transform(({ value }) => {
    return String(value);
  })
  @IsNumberString({}, { message: '父级id必须是数字或数字字符串' })
  parentId?: string;

  // 状态 (1-正常 0-禁用)
  @IsIn([0, 1], { message: '状态值只能是0或1' })
  status?: number;

  @Transform(({ value }) => {
    return String(value);
  })
  @IsNumberString({}, { message: '排序值必须是数字或数字字符串' })
  sort?: string;

  @IsStringRw()
  @IsOptional()
  treePath?: string | undefined;
}
